/*
 * @Author: ReinerLau lk850593913@gmail.com
 * @Date: 2022-09-14 13:23:00
 * @LastEditors: ReinerLau lk850593913@gmail.com
 * @LastEditTime: 2022-09-14 13:26:15
 * @FilePath: \robot\src\views\patroling\composables\useCameraLink.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ref, watch } from "vue";
import { getByCode } from "@/api/robot-camera.js";

export default (caritem) => {
  // 视频连接栏位
  const columns2 = [
    {
      title: "编号",
      prop: "id",
    },
    {
      title: "摄像头名称",
      prop: "name",
    },
    {
      title: "品牌",
      prop: "brand",
    },
    {
      title: "ip地址",
      prop: "ip",
    },
    {
      title: "端口",
      prop: "port",
    },
    {
      title: "关联车辆",
      prop: "rid",
    },
  ];

  // 视频连接数据
  const list2 = ref([]);
  /**
   * @description: 获取视频连接数据
   * @return {*}
   */
  async function getCarCamera() {
    if (caritem.value === "") return;
    const { data } = await getByCode(caritem.value, "patroling");
    list2.value = data || [];
  }
  getCarCamera();

  watch(caritem, getCarCamera);

  return {
    columns2,
    list2,
  };
};
